/**
 * 
 */
package com.qdairlines.controller.file;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qdairlines.common.ControllerUtil;
import com.qdairlines.common.Page;
import com.qdairlines.common.PageUtil;
import com.qdairlines.constant.BaseConsts;
import com.qdairlines.constant.RequestConsts;
import com.qdairlines.controller.base.BaseController;
import com.qdairlines.entity.file.FastDFSFile;
import com.qdairlines.service.file.FileAdminService;

/**
 * @author pangyannan
 * @date 2017年6月5日
 * @company QingDao Airlines
 * @description 文件管理页面控制器
 */
@Controller
@RequestMapping("fileAdmin")
public class FileAdminController extends BaseController{
	@Autowired
	private FileAdminService fileAdminService;
	
	/**
	 * 进入文件管理页面
	 * @return
	 */
    @RequestMapping( value = "toListPage" ,produces =RequestConsts.PRODUCES)
    public String toListPage(HttpServletRequest request,Model model) {
    	model.addAttribute(BaseConsts.LANGUAGE, ControllerUtil.getLanguage(request));
    	return "/file/filelist";
    }	

    /**
     * 文件清单数据Page
     * @param request
     * @param dictionary
     * @return
     */
    @RequestMapping(value = "pageFile",produces = RequestConsts.PRODUCES)
    @ResponseBody
    public String pageDictionary(HttpServletRequest request,FastDFSFile fastDFSFile) {
    	if(StringUtils.isEmpty(fastDFSFile.getFileName())){
    		fastDFSFile.setFileName(null);
    	}
    	Page page = fileAdminService.listDate(fastDFSFile, PageUtil.getPageFromRequest(request));
    	return ControllerUtil.getJsonDateTime(page);
    }
    
    /**
     * 文件添加
     * @return
     */
    @RequestMapping( value = "toFileAddPage" ,produces =RequestConsts.PRODUCES)
    public String toFileAddPage() {
    	return "/file/fileadd";
    }	
 
    
}
